{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "from keras.datasets import mnist\n",
    "from matplotlib import pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADVNJREFUeJzt3X+s3XV9x/HXi9LeQsGsHVC6tlLK6lwDinotizUGwyAVtxS3yOy2rFs2r8sk0cxtItkiWfaDuIFjbiGro7NE5ceiQJcVJzYaYGLlljAotmplBUqbFla3ghn9+d4f99vlWu75nNtzvud8z73v5yO5Oed8398f7570db/n3M/3nI8jQgDyOa3pBgA0g/ADSRF+ICnCDyRF+IGkCD+QFOEHkiL8QFKEH0jq9H4ebJaHYrbm9POQQCqv6kc6HIc8mXW7Cr/tVZJulTRD0j9GxE2l9Wdrji7zFd0cEkDBltg86XU7ftlve4akv5f0HknLJa2xvbzT/QHor27e86+QtDMinomIw5LukrS6nrYA9Fo34V8o6flxj3dXy36M7RHbo7ZHj+hQF4cDUKduwj/RHxVe8/ngiFgXEcMRMTxTQ10cDkCdugn/bkmLxz1eJGlPd+0A6Jduwv+YpGW2L7Q9S9IHJG2spy0AvdbxUF9EHLV9naR/09hQ3/qIeLq2zgD0VFfj/BGxSdKmmnoB0Edc3gskRfiBpAg/kBThB5Ii/EBShB9IivADSRF+ICnCDyRF+IGkCD+QFOEHkiL8QFKEH0iK8ANJEX4gKcIPJEX4gaQIP5AU4QeSIvxAUoQfSIrwA0kRfiApwg8kRfiBpAg/kBThB5Ii/EBSXc3Sa3uXpJclHZN0NCKG62gKQO91Ff7KuyPip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Li4mrZpyQdiIibql+ccyPi4wPS242SXml65uZqQpkF42eWlnSNpN9Ug89doa9r1cDz1sSZf4WknRHxTEQclnSXpNUN9DHwIuIhSQdOWrxa0obq/gaN/efpuxa9DYSI2BsRj1f3X5Z0YmbpRp+7Ql+NaCL8CyU9P+7xbg3WlN8h6au2t9oeabqZCcw/MTNSdXtew/2crO3Mzf100szSA/PcdTLjdd2aCP9Es/8M0pDDyoh4q6T3SPpw9fIWkzOpmZv7ZYKZpQdCpzNe162J8O+WtHjc40WS9jTQx4QiYk91u1/SvRq82Yf3nZgktbrd33A//2+QZm6eaGZpDcBzN0gzXjcR/sckLbN9oe1Zkj4gaWMDfbyG7TnVH2Jke46kqzR4sw9vlLS2ur9W0v0N9vJjBmXm5lYzS6vh527QZrxu5CKfaijjbyTNkLQ+Iv68701MwPZSjZ3tpbFJTL/YZG+275R0ucY+9bVP0icl3SfpHkmvl/ScpPdHRN//8Nait8t1ijM396i3VjNLb1GDz12dM17X0g9X+AE5cYUfkBThB5Ii/EBShB9IivADSRF+ICnCDyRF+IGk/g8U2sllFK2yjAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "(X_train, y_train), (X_test, y_test) = mnist.load_data()\n",
    "plt.imshow(X_train[100,:,:])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((60000, 28, 28), (60000,), (10000, 28, 28), (10000,))"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.shape(X_train), np.shape(y_train), np.shape(X_test), np.shape(y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train = X_train.reshape(60000, 28*28)\n",
    "X_test = X_test.reshape(10000, 28*28)\n",
    "X_train = X_train/255\n",
    "X_test = X_test/255\n",
    "X_train = X_train.astype(\"float32\")\n",
    "X_test = X_test.astype(\"float32\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
